<template>
    <div class="box">
        <header class="header">
            我的
        </header>
        <div class="content">
            <div style="display:flex;justify-content: space-between;">
                <p> 用户名：{{ username }}</p>
                <van-button type="default" size="small" @click="loginout">退出登录</van-button>
            </div>
            <div>
                <van-button type="warning" @click="$router.push('/myorder')">查看我的订单</van-button>
            </div>
        </div>
    </div>
</template>
<script>
import { useRouter } from 'vue-router'
export default {
    setup() {
        const username = localStorage.getItem('username')
        const router = useRouter()
        const loginout = () => {
            // 清除token
            localStorage.removeItem('token')
            // 清除用户名
            localStorage.removeItem('username')
            // 跳转到登录页
            router.push('/login')
        }
        return {
            username,
            loginout
        }
    }
}
</script>